package com.xsprite.managesys.service;

import java.util.LinkedList;
import java.util.Queue;

import com.xsprite.managesys.bean.Message;

public class MessageManager {
	
	private static MessageManager instance;
	
	public static MessageManager getInstance(){
		if(instance == null){
			instance = new MessageManager();
		}
		return instance;
	}
	
	private Queue<Message> msgQueue = new LinkedList<Message>();
	
	public void addMessage(Message msg){
		msgQueue.add(msg);
	}

	public synchronized Message pollMessage(){
		if(msgQueue.size() > 0){
			return msgQueue.poll();
		}
		return null;
	}
}
